﻿/*
 * My Timer - cdThreading.cs
 * 
 * Copyright (C) 2009 Ahmad Hanis Azmi
 * 
 * This file is part of My Timer
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading;
using System.Text;
using System.Windows.Forms;

namespace My_Timer
{
    public class cThreading
    {
        private static string _s;

        public static void try_Start(string s)
        {
            Thread tTryStart = new Thread(doTry_Start);
            _s = s;

            tTryStart.Start();
        }

        public static void doTry_Start()
        {
            try
            {
                System.Diagnostics.Process.Start(_s);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not start \"" + _s + "\".\n\nError: " + ex.Message,
                    "My Timer", MessageBoxButtons.OK, MessageBoxIcon.Error);

#if DEBUG
                MessageBox.Show("Error caught in try_Start. Error: " + ex.Message);
#endif
            }

            _s = null;
        }
    }
}